#include <stdio.h>

int main()
{
	int a[][4] = {{1, 0, 1, 1},{0, 2, 3, 4},{5, 6, 1, 0},{2, 3, 1, 4}};

	int i, j;

	int ROWS = 4;
	int COLS = 4;

	int rows[ROWS], cols[COLS];

	for (i=0; i < ROWS; i++)
		rows[i] = 0;

	for (i=0; i < COLS; i++)
		cols[i] = 0;

	printf ("\nInput Matrix:\n");
	for (i=0; i < ROWS; i++) {
		for (j=0; j < COLS; j++)
			printf ("%d\t", a[i][j]);
		printf ("\n");
	}


	for (i=0; i < ROWS; i++) {
		for (j=0; j < COLS; j++) {
			if (a[i][j] == 0) {
				rows[i] = 1;
				cols[j] = 1;
			}
		}
	}


	printf ("\nOutput Matrix:\n");
	for (i=0; i < ROWS; i++) {
		for (j=0; j < COLS; j++) {
			if (rows[i] || cols[j])
				printf ("0\t");
			else
				printf ("%d\t", a[i][j]);
		}
		printf ("\n");
	}

	return 0;
}
